Change occurences of assert (0) into babl_fatal()
authorDanny Robson <danny@blubinc.net>
Sun, 19 Jul 2009 12:50:37 +0000 (22:50 +1000)
committerMartin Nordholts <martinn@src.gnome.org>
Sun, 19 Jul 2009 13:43:04 +0000 (15:43 +0200)
babl_fatal() is the more appropriate method to die upon failure, so
all instances of assert (0) have been changed into babl_fatal() with
some attempt of an error message.

In this process, the babl_fish_process() method was refactored into
using the existing case statement.

Bug #589027.

babl/babl-fish-stats.c
babl/babl-fish.c

index 5348303d03635aefc6cd9bf4b1b6ee424674cb6f..cb83b0e8591ccac1850e81deac06dede65bf92aa 100644 (file)
@@ -132,7 +132,7 @@ table_destination_each (Babl *babl,
             break;
 
           default:
-            babl_assert (0);
+            babl_fatal ("Unknown fish type");
             break;
         }
     }
index 622ca25737c14315794045934242872d4aa76180..ae25bcb462b24b2b6f71dddf46120e9362df71a1 100644 (file)
@@ -291,37 +291,33 @@ babl_fish_process (Babl *babl,
   switch (babl->class_type)
     {
       case BABL_FISH_REFERENCE:
-      case BABL_FISH_SIMPLE:
-      case BABL_FISH_PATH:
-        if (babl->class_type == BABL_FISH_REFERENCE)
+        if (babl->fish.source == babl->fish.destination)
+          { /* XXX: we're assuming linear buffers */
+            memcpy (destination, source, n * babl->fish.source->format.bytes_per_pixel);
+            ret = n;
+          }
+        else
           {
-            if (babl->fish.source == babl->fish.destination)
-              { /* XXX: we're assuming linear buffers */
-                memcpy (destination, source, n * babl->fish.source->format.bytes_per_pixel);
-                ret = n;
-              }
-            else
-              {
-                ret = babl_fish_reference_process (babl, source, destination, n);
-              }
+            ret = babl_fish_reference_process (babl, source, destination, n);
           }
-        else if (babl->class_type == BABL_FISH_PATH)
+        break;
+
+      case BABL_FISH_SIMPLE:
+        if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
           {
-            ret = babl_fish_path_process (babl, source, destination, n);
+            ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
+                                           source, destination, n);
           }
-        else if (babl->class_type == BABL_FISH_SIMPLE)
+        else
           {
-            if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
-              {
-                ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
-                                               source, destination, n);
-              }
-            else
-              {
-                babl_assert (0);
-              }
+            babl_fatal ("Cannot use a simple fish to process without a linear conversion");
           }
         break;
+
+      case BABL_FISH_PATH:
+        ret = babl_fish_path_process (babl, source, destination, n);
+        break;
+
       default:
         babl_log ("NYI");
         ret = -1;